package com.woniuxy.mini;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.core.service.SocialRelationshipService;
import com.woniuxy.entity.AllUser;
import com.woniuxy.entity.DTO.UserInfoDTO;
import com.woniuxy.util.ResponseData;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 饶志
 * @version 1.0
 * @since 2025-07-13  21:17
 */
@RestController
@RequestMapping("/mini/social")
@RequiredArgsConstructor
public class SocialController {

    private final SocialRelationshipService socialRelationshipService;

    /**
     * 获取用户的关注列表（分页）
     *
     * @param userId      用户ID
     * @param currentPage 当前页（默认1）
     * @param size        每页大小（默认10）
     * @return 关注列表分页结果
     */
    @GetMapping("/followList/{userId}")
    public ResponseData<Page<UserInfoDTO>> getFollowList(
            @PathVariable(name = "userId") Integer userId,
            @RequestParam(name = "currentPage", defaultValue = "1") Long currentPage,
            @RequestParam(name = "size", defaultValue = "10") Long size) {
        Page<UserInfoDTO> page = new Page<>(currentPage, size);
        Page<UserInfoDTO> followList = socialRelationshipService.getFollowList(userId, page);
        return ResponseData.ok(followList);
    }

    /**
     * 获取用户的粉丝列表（分页）
     *
     * @param userId      用户ID
     * @param currentPage 当前页（默认1）
     * @param size        每页大小（默认10）
     * @return 粉丝列表分页结果
     */
    @GetMapping("/fansList/{userId}")
    public ResponseData<Page<UserInfoDTO>> getFansList(
            @PathVariable(name = "userId") Integer userId,
            @RequestParam(name = "currentPage", defaultValue = "1") Long currentPage,
            @RequestParam(name = "size", defaultValue = "10") Long size) {
        Page<UserInfoDTO> page = new Page<>(currentPage, size);
        Page<UserInfoDTO> fansList = socialRelationshipService.getFansList(userId, page);
        return ResponseData.ok(fansList);
    }

    /**
     * 获取用户的互关列表（分页）
     *
     * @param userId      用户ID
     * @param currentPage 当前页（默认1）
     * @param size        每页大小（默认10）
     * @return 互关列表分页结果
     */
    @GetMapping("/mutualFollowList/{userId}")
    public ResponseData<Page<UserInfoDTO>> getMutualFollowList(
            @PathVariable(name = "userId") Integer userId,
            @RequestParam(name = "currentPage", defaultValue = "1") Long currentPage,
            @RequestParam(name = "size", defaultValue = "10") Long size) {
        Page<UserInfoDTO> page = new Page<>(currentPage, size);
        Page<UserInfoDTO> mutualFollowList = socialRelationshipService.getMutualFollowList(userId, page);
        return ResponseData.ok(mutualFollowList);
    }

    /**
     * 推荐好友
     *
     * @param userId 用户ID
     * @param count  推荐好友数量
     * @return 推荐好友列表
     */
    @GetMapping("/recommendFriends/{userId}")
    public ResponseData<List<UserInfoDTO>> recommendFriends(@PathVariable(name = "userId") Long userId) {
        List<UserInfoDTO> recommendFriends = socialRelationshipService.recommendFriends(userId);
        return ResponseData.ok(recommendFriends);
    }

}
